# Maintainer: Alex McGrath <amk@amk.ie>
pkgname=foot
pkgver=1.17.2
pkgrel=0
pkgdesc="Fast, lightweight and minimalistic Wayland terminal emulator"
url="https://codeberg.org/dnkl/foot"
license="MIT"
arch="all"
depends="ncurses-terminfo"
makedepends="
	cage
	font-dejavu
	fcft-dev
	fontconfig-dev
	freetype-dev
	libxkbcommon-dev
	meson
	ncurses
	pixman-dev
	scdoc
	tllist-dev
	utf8proc-dev
	wayland-dev
	wayland-protocols
	"
subpackages="
	$pkgname-dbg
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	$pkgname-extra-terminfo:_extra_terminfo:noarch
	$pkgname-themes:_themes:noarch
	"
source="
	$pkgname-$pkgver.tar.gz::https://codeberg.org/dnkl/foot/archive/$pkgver.tar.gz
	"
options="!check" # ran during profiling
builddir="$srcdir/foot"

build() {
	export CFLAGS="$CFLAGS -O3" # -O3 as the package is intended to use it
	export CXXFLAGS="$CXXFLAGS -O3"
	export CPPFLAGS="$CPPFLAGS -O3"

	abuild-meson \
		-Db_pgo=generate \
		-Db_lto=true \
		-Dterminfo-base-name=foot-extra \
		-Dutmp-backend=none \
		. output
	meson compile -C output

	ninja -C output test
	./pgo/full-headless-cage.sh . output

	meson configure -Db_pgo=use output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_extra_terminfo() {
	pkgdesc="$pkgdesc (extra terminfo data)"

	amove /usr/share/terminfo/f
}

_themes() {
	pkgdesc="$pkgdesc (color schemes)"

	amove /usr/share/foot/themes
}

sha512sums="
72a9fc5ec38c2cb8417b74c3089c82d7a0c0090339ab2312df3d1eafc442e5254ae79f9dcfefa50d8866e77a5776aa6fc5727a758f792986abf0cfb9b4f0658e  foot-1.17.2.tar.gz
"
